<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		    <div id="app">
		    	<button id="demo1" dataid = "1001" type="button" @click="add">增加1</button>
				<button id="demo2" dataid = "1002" type="button" @click="add">增加2</button>
				<button type="button" v-on:click="addN(10)">增加10</button>
				<p>{{num}}</p>
		    </div>
			<script src="./node_modules/vue/dist/vue.js" type="text/javascript" charset="utf-8"></script>
			<script>
				let app=new Vue({
					el:'#app',
					data:{
						num:0
					},
					methods:{
						add(e){
							//e就是点击的对象
							//判断事件源实岁
							//附加属性
							//this.num++;
							//let dataId=e.target.attributes[1].data-id;
							console.log(e.target.attributes.dataid.value);
						},
						addN(n){
							this.num+=n;
						}
					}
					
				})
				
			</script>
	</body>
</html>
